'''
Created on Sep 28, 2009

@author: Roni
'''
import cliques.dynamicRunner
from cliques.randomCliqueSearch import randomCliqueSearch
from cliques.knownDegreeSearch import knownDegreeSearch
from cliques.cliqueStarSearch import cliqueStarSearch
from cliques.cliqueSearchLowerbound import CliqueSearchLowerbound
from cliques.mdp.offlineLimitedSampling import OfflineLimitedSampling
from cliques.mdp.mdpBasedSearch import mdpBasedSearch
import graphUtils.scaleFreeGenerator
import graphUtils.folderGenerator
import logging
import sys

def main():
    logging.basicConfig(level=logging.INFO)
    logging.root.addHandler(logging.StreamHandler(sys.stdout)) 
       
    algorithm_tuple = (randomCliqueSearch(),knownDegreeSearch(),cliqueStarSearch(),\
            mdpBasedSearch(OfflineLimitedSampling,"OfflineLimitedSampling-3-10-0.5",3,10,noise=0.5),\
            mdpBasedSearch(OfflineLimitedSampling,"OfflineLimitedSampling-3-25-0.5",3,25,noise=0.5),\
            mdpBasedSearch(OfflineLimitedSampling,"OfflineLimitedSampling-3-50-0.5",3,50,noise=0.5),\
#            mdpBasedSearch(OfflineLimitedSampling,"OfflineLimitedSampling-3-500-0.5",3,500,noise=0.5),\
#            mdpBasedSearch(OfflineLimitedSampling,"OfflineLimitedSampling-3-1000-0.5",3,1000,noise=0.5),\
            CliqueSearchLowerbound());

    graph_folder = "../resources/graphs/web"
    graph_generator = graphUtils.folderGenerator.folderIndexGraphGenerator(graph_folder)
    sampling_effect_runner = cliques.dynamicRunner.dynamicRunner("web-300", algorithms=algorithm_tuple,\
                                                      nodes_range=[300],\
                                                      edge_factors=[3],\
                                                      k_range=xrange(4,11),\
                                                      num_of_graphs=25,iterations_per_graph=100,\
                                                      graph_generator_method=graph_generator.createIndexGraphFromFolder,\
                                                      enable_profiling=False)
    sampling_effect_runner.run()
    
    sampling_effect_runner = cliques.dynamicRunner.dynamicRunner("sampling_effect_scale_free", algorithms=algorithm_tuple,\
                                                              nodes_range=[100],\
                                                              edge_factors=[8,12,16],\
                                                              num_of_graphs=50,\
                                                              k_range=xrange(5,9),\
                                                              graph_generator_method=graphUtils.scaleFreeGenerator.createScaleFree,\
                                                              enable_profiling=False)
    sampling_effect_runner.run()

    sampling_effect_runner = cliques.dynamicRunner.dynamicRunner("sampling_effect", algorithms=algorithm_tuple,\
                                                              nodes_range=[100],\
                                                              edge_factors=[8,12,16],\
                                                              num_of_graphs=50,\
                                                              k_range=xrange(5,9),\
                                                              enable_profiling=False)
    sampling_effect_runner.run()

if __name__ == '__main__':
    main()